package com.jwaoo.chat.session.recent.holder;
import com.dx.as.LoadingDialog;
import com.dx.as.common.ILoadListener;
import com.dx.as.common.file.AttachmentStore;
import com.dx.as.common.string.StringUtil;
import com.dx.as.db.IDBListener;
import com.dx.as.db.SqlLiteHelper;
import com.jwaoo.chat.ChatConstants;
import com.jwaoo.chat.ChatHelpter;
import com.jwaoo.chat.Message;
import com.jwaoo.chat.activity.module.fromapp.AppInstance;
import com.jwaoo.chat.data.db.ChatDatabase;
import com.jwaoo.chat.data.db.MessageHandler;
import com.jwaoo.chat.fragment.session.bean.SessionBean;
import com.jwaoo.chat.ui.recyclerview.adpter.BaseQuickAdapter;
import java.util.List;
import static com.jwaoo.chat.data.db.MessageHandler.DELETE_ALL_MESSAGE;
import static com.jwaoo.chat.data.db.MessageHandler.GET_ALL_MESSAGE_BY_ID;

public class SessionViewHolder extends RecentViewHolder {

    public SessionViewHolder(BaseQuickAdapter adapter) {
        super(adapter);
    }

    protected String descOfMsg(SessionBean recent) {
        String digest = null;
        if (getCallback() != null) {
            digest = getCallback().getDigestOfAttachment(recent.getMsgtype());
        }
        if (digest == null) {
            digest = getDefaultDigest(recent);
        }
        return digest;

    }


    // SDK本身只记录原始数据，第三方APP可根据自己实际需求，在最近联系人列表上显示缩略消息
    // 以下为一些常见消息类型的示例。
    private String getDefaultDigest(SessionBean recent) {
        String snapStr = "";
        if (recent.getSnap() == ChatConstants.snap)
            snapStr = "[阅后即焚]";
        switch (recent.getMsgtype()) {
            case ChatConstants.text:
                if (StringUtil.isEmpty(snapStr))
                    return recent.getContent();
                else return snapStr+"[文本]";
            case ChatConstants.image:
                return snapStr+"[图片]";
            case ChatConstants.video:
                return snapStr+"[视频]";
            case ChatConstants.audio:
                return snapStr+"[语音消息]";
            case ChatConstants.audio_chat:
                return "[语言电话]";
            case ChatConstants.video_chat:
                return "[视频电话]";
            case ChatConstants.notification:
            default:
                return "[自定义消息] ";
        }
    }
}
